﻿using System;
using System.Collections.Generic;
using System.Linq.Expressions;

namespace lindyaka.Repository
{
    /// <summary>
    ///     Repository main interface
    /// </summary>
    /// <typeparam name="TEntity">entity type of the repository</typeparam>
    public interface IRepository<TEntity>
    {
        /// <summary>
        ///     Add an item to repository
        /// </summary>
        /// <param name="item">item to add</param>
        void Add(TEntity item);

        /// <summary>
        ///     Delete specific entities by query (Expression)
        /// </summary>
        /// <param name="query">Expression to evaluate</param>
        void Remove(Expression<Func<TEntity, bool>> query);

        /// <summary>
        ///     Update entity into the repository
        /// </summary>
        /// <param name="item">Item with changes</param>
        void Update(TEntity item);

        /// <summary>
        ///     Get all entities
        ///     Implement 'FindBy' by preference first
        /// </summary>
        /// <returns>all entity</returns>
        IEnumerable<TEntity> FindAll();

        /// <summary>
        ///     Get specific entity by query (Expression)
        /// </summary>
        /// <param name="query">Expression to evaluate</param>
        /// <returns>Item matching query</returns>
        TEntity Find(Expression<Func<TEntity, bool>> query);

        /// <summary>
        ///     Get specific entity by query (Expression)
        /// </summary>
        /// <param name="query">Expression to evaluate</param>
        /// <returns>Item matching query</returns>
        IEnumerable<TEntity> FindMany(Expression<Func<TEntity, bool>> query);
    }
}